import { request } from "@/utils/service"
import type * as Login from "./types/login"
import type {BaseUserData, resp} from "./types/login";

/** 获取登录验证码 */
export function getLoginCodeApi() {
  return request<Login.LoginCodeResponseData>({
    url: "/public/login/code",
    method: "GET"
  })
}

/** 登录并返回 Token */
export function loginApi(data: Login.LoginRequestData) {
  return request<resp>({
    url: "/public/users/login",
    method: "POST",
    data
  })
}

/**
 * 小程序登录
 * @param data 请求参数
 */
export const loginWxAPI = (data: any) => {
  return request<resp>({
    method: 'POST',
    url: '/login/wxMin',
    data,
  })
}

/** 登录并返回 Token */
export function logoutApi(token: string) {
  return request<resp>({
    url: "/private/users/logout?token=" + token,
    method: "GET"
  })
}

/** 获取用户详情 */
export function getUserInfoApi() {
  return request<Login.UserInfoResponseData>({
    url: "/private/users/info",
    method: "GET"
  })
}

export function getUserProfile() {
  return request<BaseUserData>({
    url: '/private/users/profile/get',
    method: 'GET'
  })
}
